import Tips from './Tips';

/**
 * 支付功能[todo]
 * 
 * @export
 * @class Payment
 * [支付未完成](http://www.html5plus.org/doc/zh_cn/payment.html#plus.payment.PaymentChannel.requestOrder)
 */
export default class Payment {

    /**
     * 打开支付功能
     * 
     * @static
     * 
     * @memberOf Payment
     * 
     */
    static openPayment() {
        return new Promise((resolve, reject) => {
            plus.payment.getChannels(channels => {
                const items = channels.map(item => {
                    return {
                        title: item.description
                    };
                });
                Tips.action('支付', items)
                    .then(index => {
                        const channel = channels[index - 1];
                        // channel.send({
                        //     content: option.title,
                        //     href: option.url,
                        //     extra: {
                        //         scene: "WXSceneTimeline"
                        //     }
                        // }, () => {
                        //     resolve();
                        // }, error => {
                        //     reject(error);
                        // });
                    });
            }, error => {
                reject(error);
            });
        });
    }
}